﻿using IXION.BLOG.COMMON.DATE;
using IXION.BLOG.DAO.BLOG;
using IXION.BLOG.DOMAIN.BLOG;
using System;
using System.Collections.Generic;
using System.Text;

namespace IXION.BLOG.SERVICE.ARTICLE
{
    public class ArticleService
    {
        protected ArticleDao dao = new ArticleDao();
        public IList<Article> GetArticles(int start, int count)
        {
            return dao.GetArticles(start,count);
            //throw new NotImplementedException();
        }

        public int CountArticles()
        {
            return dao.ListAllArticles().Count;
            //throw new NotImplementedException();
        }

        public Article GetArticleById(int p)
        {
            return dao.FindArticleById(p);
            //throw new NotImplementedException();
        }
        /// <summary>
        /// 按照发表时间搜索
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public IList<Article> SearchArticlesByPostDay(string value,int start,int count)
        {
            return dao.SearchArticlesByPostDay(DateUtils.GetDayBegin(value),DateUtils.GetDayEnd(value),start,count);
            //throw new NotImplementedException();
        }
        /// <summary>
        /// 安装关键字搜索
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public IList<Article> SearchArticlesByKey(string value, int start, int count)
        {
            return dao.SearchArticlesByKey(value, start, count);
            //throw new NotImplementedException();
        }

        public int CountArticlesByDay(string value)
        {
            return dao.SearchArticlesByPostDay(DateUtils.GetDayBegin(value), DateUtils.GetDayEnd(value)).Count;
            //throw new NotImplementedException();
        }

        public int CountArticlesByKey(string value)
        {
            return dao.SearchArticlesByKey(value).Count;
            //throw new NotImplementedException();
        }
    }
}
